<template>
  <main class="w-full h-full p-8">
    <el-button type="primary" @click="goBack">返回</el-button>
    <div class="w-full h-full flex justify-center items-center">
      <ProgressForm v-if="pageType === 'form'" ref="progressForm"></ProgressForm>
      <ProgressResult
        v-if="pageType === 'result'"
        ref="progressResult"
        :status="status"
      ></ProgressResult>
    </div>
  </main>
</template>
<script lang="ts" setup>
import { useRouter } from 'vue-router'
import ProgressForm from './progressForm.vue'
import ProgressResult from './progressResult.vue'

const status = ref(0)
const router = useRouter()
const pageType = ref('form')
const route: Record<string, any> = useRoute()

watch(
  () => route.query,
  (value: Record<string, any>) => {
    pageType.value = value.type || 'form'
    status.value = value.status ? Number(value.status) : 0
  }
)

const goBack = () => {
  router.push({ path: '/login' })
}

onMounted(() => {
  pageType.value = route.query.type || 'form'
  status.value = Number(route.query.status) || 0
})
</script>
